import 'package:flutter/material.dart';
import 'package:freemusic/page/search/SearchPage.dart';
import 'package:freemusic/utils/Util.dart';

class SearchWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SearchState();
  }
}

class SearchState extends State<SearchWidget> {
  void handleOnSearch() {
    Navigator.push(
        context, MaterialPageRoute(builder: (context) => SearchPage()));
  }

  void handleMoreOnClick() {
    Scaffold.of(context).openDrawer();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
        top: 40.0,
        bottom: 40.0,
      ),
      child: Row(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(left: 10, right: 10),
            child: Text(
              "Music",
              style: TextStyle(
                fontSize: 22,
                color: Util.themeColor,
              ),
            ),
          ),
          Expanded(
            child: Container(
              height: 34,
              margin: EdgeInsets.only(left: 8),
              child: TextField(
                onTap: this.handleOnSearch,
                readOnly: true,
                decoration: InputDecoration(
                  hintText: "输入你想听的歌曲名称",
                  fillColor: Colors.white,
                  filled: true,
                  contentPadding: EdgeInsets.only(left: 5.0, right: 5.0),
                  border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(16.0),
                      borderSide: BorderSide.none),
                ),
              ),
            ),
          ),
          IconButton(
            icon: Image.asset("images/more.png"),
            onPressed: this.handleMoreOnClick,
          )
        ],
      ),
    );
  }
}
